package zuoye.zy1;
import cn.hutool.core.io.FileUtil;
import org.apache.commons.io.FileUtils;

import java.io.File;

public class Test {
    public static void main(String[] args) throws Exception {
//        复制文件夹中的所有
      File src = new File("D:\\演示\\7.23");
//      获取每一个文件
        File[] files = src.listFiles();
        for (File file : files) {
//            后缀名为java
            if (file.getName().endsWith(".java")) {
                FileUtils.copyFileToDirectory(file, new File("D:\\演示\\7.23.2"));
                System.out.println("复制成功");
            }
        }
        File src2= new File("D:\\演示\\7.23.2");
        File[] files2 = src2.listFiles();
        for (File file : files2){
            String newName = FileUtil.mainName(file) + ".txt";
            FileUtil.rename(file, newName, true);
        }





    }
}
